Modified MexWrapperGenerator

Added code to write generated glue code to file.
Bug fix