Improve error messages

When reading/writing files or XML parsing fails, give more details.