Escape special characters when serializing