Fix bug in writing non-string attributes