catching error for invalid images