The mean shape of transition and first-passage paths