encode instead of decode when writing attributes