Fixed bug of handling images