[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.
I think these functions can be renamed to `serializeStream`, `deserializeStream`, etc. That is, remove `data` from the names.