Python3 compatibility and some packaging fixes