Without code to look at, all anyone can do is just toss out guesses. If you make your code available via Github it's easier to analyze! That said, do you use the handle_appfocus function? I have a routine (including checking persistent variables) that I run the first time through, set via a flag. In handle_appfocus (when the face gets focus after not having it) I reset the flag and so check all my persistent variables again. I've had bugs where I put in an APP_LOG display after every line, and I was finally able to squash the bug. Good luck.
Edit: More thoughts...The problem probably isn't that you're handling an image, but the way you are saving/restoring the key to what that image should be.