Fixed encoding bug and added a function to compress

data. Currently the compress function only gets the
partial sum of the lengths needed for encoding. This
will be needed so encoding can be done in parallel.