I just bought an iMac with Mavericks pre-installed, can i go back to Mountain Lion?
Older OS X versions might not include all drivers/kernel extensions required on current hardware so the general answer is No. 

Apple has a nice article elaborating why this is a bad idea in general, but if you want to learn and have a backup of all your data, you could always try and see how far you get.

Also, just because your Mac shipped with Mavericks, doesn't necessarily mean that model isn't fully supported on an earlier version. You could check your exact model and determine whether your intended OS + Hardware combination is an exception to the general rule.

Assuming your iMac is the one marketed by Apple as Late 2013 - they yes, it will support installation of OS X 10.8.4 - Build 12E4022.

Having said that, an easy way out would be to run Mountain Lion in a VM (both VMware and Parallels will do).