Fix length encoding

http://msdn.microsoft.com/en-us/library/windows/desktop/bb648641%28v=vs.85%29.aspx