Catch all exception types when writing attributes and parameters

* Used to catch only IOError
* Thank to Andy Grover and Krzysztof Chojnowski for reporting this