Don't declare encoder if not used.

If the encoder wasn't used in a function, the Go compiler would not compile the file.