Sorry but there is nothing you can do in software to detect those faulty images. This is because you have not got enough memory in the arduino to store an image and look at it before you store it.
What you have to do is to stop the errors happening in the first place. The place to start would be to improve the decoupling of your system.