Stop iMac from sleeping when used as an external display
Theres a very popular app called caffeine that sits an icon in your menu bar, and when you click it the app prevents your computer from sleeping either indefinitely or for a predetermined period of time.