You need to use palette converter. Either built-in (in some painting program for example) or stand alone (although I do not know any). As for me, I use XWE (eXtendable Wad Editor) which has built-in palette converter and adjusts image palette automatically according to main game WAD's palette. Unfortunately I have no access to my home computer right now, so I cannot tell you where to get it, sorry. Maybe later. Or maybe someone else will help you.