Avoid creating a bunch of temporary strings when encoding

Use a bytes.Buffer instead