Add Python 3 support

Fixes #1
Includes some simple tests.