Implemented greatly improved color reduction algorithm

- used for palette creation in various BAM, MOS and TIS conversion
routines