Speed up driver

Re-arrange the code as a state machine to give > 30% speedup. Also a
few other changes:

* Make 'named' the default paramstyle (PEP 249 doesn't seem to like
  'format')

* Make 'threadsafety' 2, so threads can't share cursors.

* Connect by doing pg8000.connect() rather than pg8000.DBAPI.connect()

* Replace Bytea type with built-in 'bytes' type.