Fixes for Python code generation

Various fixes to get generated Python code running. Tested with Bugenhagen 2010 and with Iancu, Jones, Harvey, 2007 by visually comparing plotted output with that from OpenCOR.