Fix setting custom colors in palette

 * There was an error in the way the index
   was computed.
 * Fixes #18