Add an option to write completed and merged model to a file

Change-Id: I583e14a9b598ce2b3b86b5728925e4518e7d952e