Add format_solution function back for external solver

This function is a required part of the interface, so although
the solution object is still returned by solve_problem, the code to
create it moves to this format_solution function.
Add code to remove temporary folder and its contents upon exiting