Fix an off by one error in encoding this off by one error doesn't seems to reproduce on linux but the error is real.