genmidi: Update to support Python 3 build.

Tweak the code used to build the GENMIDI Lump so that it properly
supports Python 3 for build. Tested use cases were:
 * Normal build
 * a2i-to-sbi script to convert AdTrack2 instruments to SBI format
 * dumpgenmidi script to dump the instruments from a GENMIDI lump.
 * Running genmidi.py, sbi_file.py, a2i_file.py standalone to print the
   contents of files in their respective formats.
Update other scripts to support Python 3 build.

A couple of scripts were not Python 3 compatible. Update smtextgen to
use print() instead of bare print, and update the texture build script
to use the correct binary mode for writing binary files.