Convert an image to indexed color mode.