Fix the calculation of RGB values because it's little endian
Consolidate dithering code