Add in support for passing in JSON dumps functions

Hi Charles,

I've added in support for passing through a `json.dumps` function to psycopg2. I need it to serialise datetime formats going into the db, but obviously this is nice and generic.

Let me know what you think.

Cheers,
Alex