fixed a small python3 bug
fixed relying on undefined behaviour, which fails under python 3