Staples swings to loss in Q3, beats estimates