Fix python3 compatibility

Use integer division
Correct string join usage