Huge numbers to 128 bit hex

Im trying to convert big number, a really big number more then 1000 digits, I want it to be hex 128bit .

Tried using this :

def tohex(val, 128):
  return hex((val + (1 << 128)) % (1 << 128))

but with big numbers all I get is something like this :

0x0L

hex(x) function does not work also.

in the end I need to convert a really big number in to 32digits hex (128bit) any suggestions guys?