Refs #1736: It now creates the .tmp file in the same folder as the output file, and renames the old session to .bkp before moving the .tmp to the final .cys file. Also improved the error messages.

Change-Id: I8b0c0108e763ae1e4ec43164061a67502523c17c