OK, better answer, especially if you do not want to get into the coding.
Most graphics programs will handle this for you. The particular method depends on the software you are using. You want to resample the image you are using to a lower colour depth. Irfanview will do this, so will GIMP.