[WIP] [SPARK-4198] [Core] Refactor some BlockManager internals

Main goals of this PR:
  - Break up doPut and doGetLocal into component methods which are individually more readable.
  - Remove the weird "return bytes or value depending on parameter" in BlockManager.
  - Move the block-related Serialization logic out of BlockManager.

Not quite finished and tested, just wanted to get what I have so far up.
This had always confused me. This should rather be named as `startSerializationStream`, because this method does not actually write and serialize any data, only opens up the stream for the caller to write data into.