convert: Catch errors when writing tags

Fixes #878.