allow pathname object as filepath