bug fix

fixed bug where we read from the image file too soon and the file
was empty