I have a solution that worked for me!! But first some background.
I have been dealing with the screen on my iMac 27" (Mid 2011) for several months now. In the beginning it would randomly just go dark and I could not get it to come alive without shutting it down and restarting. I soon realized that it was only the screen that was shutting down, since certain key strokes produced a sound (e.g., command-shift-escape). So then I found that if I clicked the power button a few times, then I would get the logging on screen. I reset the PRAM, etc, but no help. I called Apple support and they recommended fixing everything in Disk Utilities (permissions, repair disk), but that did not improve things. I was then using Mountain Lion and they strongly recommended updating to Yosemite. I eventually did but things actually got worse. I changed my security setting to "require password after 1 minute" so that I would not have to log in after every dark screen episode.
After reading many blogs, there was much discussion about heat being the cause. While the screen was bright, I put my hand over the vents and found that every time I put my hand over the middle part of the screen (back of the iMac, near the top), the screen would go black within a few seconds. Clearly, blocking the airflow raised the temperature sufficiently that it caused the system to shut down. You should try this!
Solution: As suggested by someone in one of the blogs, I installed "smc Fan Control", a freeware utility that allows you to increase the default fan speed for the three fans that are evidently in the iMac. The utility showed that the internal temperature of my mac was 49 °C (120 °F), which seems quite hot. I set the speeds of the three fans to ca. 2000 and within 15 minutes the temperature had come down to 39 °C (102 °F), still warm, but much better. Since doing this, the computer had not gone dark on me. I should note that even at this temperature, if I block the central part of the vent slot, the computer will go dark within a few seconds. So, as long as I don't do this, I can now use my computer without the dreaded black screen.