Actually do the encoding