Bug fixing in working with images