image.c

error handling improved