Python 3 Port

Port to Python 3. Should still be compatible with Python 2. Other minor
changes such as exception handling to allow for string conversion of int
and float arguments in smart_encode_str().