Replace js encoding with server-side call.

Closes #193.