[SPARK-4109][CORE] Correctly deserialize Task.stageId

The two subclasses of Task, ShuffleMapTask and ResultTask, do not correctly deserialize stageId. Therefore, the accessing of TaskContext.stageId always returns zero value to the user.
As long as you're modifying this code, mind tossing a `Utils.tryOrIOException` here so that any errors that occur here are reported properly?  See #2932 for explanation / context.