The problem is that the variance is being calculated after bias and dark subtraction as the number of photons. Firstly, the dark current must be included in the variance (maybe this was a typo?). More importantly, the variance shouldn't be the measured number of photons but its expectation value.
Masking pixels that end up negative biases the image, and this is a problem. I think that we won't need to do any masking; if we do, we need to think harder about the consequences.
Even if the pixel must be taken as bad (which is not, I think, correct) please do not set the variance to infinity; that causes biases too. You should interpolate the variance at the same time as interpolating the image (and setting BAD).