fixed pixel to color method for non-RGB palette

This PR replaces #331