added gamma correction to palette stretching