In Python 3, the `hex' builtin function converts its operand to an
integer (using the new `__index__' special method) and then converts
that to hex, rather than calling a special method directly. The new
`bytes' type offers a `hex' method for conversion to hex, so we do the
same here.