[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.
In fact, the names can be made more imperative (similar to `wrapForCompression`): `serializeToStream`, `deserializeFromStream`, etc.