fix critical bug on python3. Fixes #47