bugfix, improved error handling and cleanup for generate_pyxelmask.py.