bug in reading image data (new filename var not being used)