Python 2 compatibility

This change makes library Python 2 compatible.