add an Encode method