Invalid image format bug fix