Implement encoder/decoder for net protocol (closes #6)