If enconding error is solved, a value error is raised in line 284. len(segments) in header should be 0.