Changed the interface to the Encode function to return a byte[].