Remove invalid characters when building path