Improve error messages in case of invalid file paths or URIs

This closes #170