fix image error handling