Fixed bug in image creation