FunctionInternal::generateCode now writes to a stream, not a file

Function::generateCode is overloaded to keep the old functionality, but it can now return a string directly
Merge pull request #1058 from ghorn/develop

FunctionInternal::generateCode now writes to a stream, not a file