bug in saving images