Fix bug in path encoding