Implementation of common dithering algorithms in PHP