Performance improvement to pg_types lookup

Reduced lookup overhead in the pg_types dictionary by have the values as
a tuple instead of a dict. Also made the format code an int rather
than a string, as it has to be converted to an int anyway.

Fixed a few instances where the 'long' type was referenced, as this
doesn't exist in Python 3 any more.