Python 3 support

Here's a new pull request based on our last round of discussions.  The previous PR was merged and then backed out.