Note: If you are reading this for the fist time, you may jump directly to the UPDATE, since it addresses the issue more accurately.
So I got a
A possible option is to load all those images that you need at the start of your script. See this TechRepublic article for more info.