Rewrite build scripts for Python 3