Fix pkg-config-wrapper to work with Python 3

The main patch is 0aa260586fab2dab3bc40157acbac9f36e50c77f. Fixes #546.

@vbraun, you wrote the original code, could you please review this?