implement two stage scan and then emit logic, so that all input pixels can be scanned before any are written out to disk. This fixes a tricky 32 bit detected as 24 bit bug and make sure that .mov and image conversion act in the same way. We no longer need a special case of writing the file twice in the 24BPP case