Fix a bug in _rgb2hex.

Small values would be converted to single-digit hexadecimal values
because of an incorrect length calculation.