The way I read the question, might be a need to change file format type to
something using only 256 colors or having an indexed "palette" because jpeg
(or jpg) image files, being non-paletted, won't have a specific index to
replace with a texture.
Section 3.5.5.3 of the Scene Help describes material_map and that could also
be useful.