Fixed bug with saving images