JavaScript port of the NeuQuant image quantization algorithm