Added check against image corruption