fix issue where certain images would cause a crash