Encode attributes