2013-04-30 - Jonathan Morgan - finished encode method.