Explicitly convert pathname to string to avoid TypeError in Ruby 2.0.