Debug Encode.java

debugged the heck out of Encode.java fixed most issues.  It appears there is only one issue remaining, which is not a problem if the number of axes is a multiple of 3.  Future revision will fix this.