My guesses are either that the file is probably open and locked in some other program when you try to blast over it, and so it won't let you.
By the way, what is the value of i? You should not use i as a variable since it's the imaginary variable. Use k or index or something else.
Also, do not use JPG format if you're doing image analysis. Use PNG instead. PNG is lossless compression and is pretty much the de facto standard these days while (the hated) JPG often gives bad compression artifacts. There will be no change to image values in a round trip save/recall using PNG like there will be with JPG.