Cache image data properly