error handling in case of corrupt image