NULL on error
flipping bits whilst updating pixels