added try-except clauses

Now if the third pass fails to phot
or create a light curve for one frame
it will continue with the rest of them
Refactor to use withWorkingDirectory

Simplified code to make use of the
withWorkingDirectory context manager