The filename instance var of the image should be initialized (in MCImage::MCImage()) to the empty string - the flag F_HAS_FILENAME, need only be used in the save / load functions. So here, we always copy the filename from 'iref' (i.e. filename = MCValueRetain(iref.filename)).