Macy's swings to profit in Q3, beats Street