working toward python 3 compatibility

This is mostly the work of @esc; my contribution so far has been to fix a few tests and rebase on master. I've also explicitly swapped in pillow rather than PIL for compatibility.

Test do not yet pass under Python 3, but I thought I would submit a PR now because:
- finishing up Python 3 compatibility might not be trivial. Notably, owslib needs to be brought up to speed (see, for example, geopython/OWSLib#151). If this is going to take a while, it would be nice to get the work done so far into master to avoid having to do it again in the future.
- this is a very old PR, and it could be nice to do this in parts rather than having a monster PR at some point in the future.

So I think this is a step in the direction of Python 3 compatibility. It would be great to get comments on any Python 2 problems.