properly encode path parts