Had that problem with my 2011 iMac. Took it to a Mac repair shop; they installed a new video card (or something to that effect). It works fine.
open