Move write part of ShuffleMapTask to ShuffleManager
Bug fix and better error message