Use Pathname#to_s instead of Pathname#to_path

Fixes #1723.