Fixed index of not approximated palette in reducer

Fixed iterative algorithm to calculate distances in palette reducer,
it was calculating more distances than needed.