Fixes invalidating image within cache when image is nil.

Fixes bug when setting image which is nil the image(=nil) was used as key to invalidate object in cache.