Fixes bug 240, as well as several integer overflows (visible as glitches) in other scaling output routines, e.g. YUV422.