Made encode_* return an Option