How do I prevent my iMac from sleeping while media is being played or streamed?
I experienced exactly the same issue. The steps to resolve the issue were the following:


delete /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist
reboot


If it won't solve it another helpful step could be resetting the SMC: http://support.apple.com/kb/HT3964?viewlocale=en_US