Add Python3 compatibility fixes reference: #169

Based on the work of Javier Lasheras on his fork → 7fe76dfb2790fd0eb4fe647e19023da15c38dc58