writedict: use write_atomic for exceptions

Also, fix calling code to handle InvalidLocation exceptions.
2 files changed