Fixes #27, or at least works around it. This deals with the issues mentioned in https://github.com/sgrif/pq-sys/pull/18, and it relies heavily on ideas from @golddranks and @clux.