BUG: Mantis-976: clamp before cast to uchar