Fix bug in getOutput: need to resize the vector to the actual encoding length.