Fix parsing of long encoding

/cc @markhibberd @raronson