Hello I had the same problem and found a way to fix it.
I have a late 2014 iMac 27" 5K that just this week started giving me image retention/burn in.
Something at first quite noticeable since I'm a photographer and I immediately noticed the issue when in photoshop.
I went ahead and turned my desktop image to white as well as tuned on the screensaver to in a way kind of exercise the screen. I used the random photo screensaver that uses a white background and shuffles photos and left it on for about 4 hrs. after those 4 hrs. I changed the screensaver to flurry view, which is a black based screen with a color swatch just swirling around the screen and left the computer on with this screensaver overnight.
This morning I checked the screen by opening up photoshop and creating an 18% gray image to make sure I could see if the image rentention/burn in was still present and it seems to be ALL GONE!!
Hope this helps!