memory usage optimizations for read and write operations

Using ```continue``` in mid-block is usually discouraged because it makes the flow a bit difficult to understand. It is good to use in the beginning of the block for skipping exceptional cases.

Code Complete 2 suggests in page 380 to use ```continue``` in the beginning of blocks. "If, on the other hand, the ```continue``` occurs toward the middle or end of the loop, use an ```if``` instead."

Using ```if/else``` may make the code a bit complicated and we need to think about how to make it simpler. If we separate this function into 2 functions, then maybe the problem is automatically solved. If we decide to keep this as one function, we can also consider having two loops instead of one. One which does the serialization and the other one which does the compression.

(As a side note, similar suggestions also apply for ```return``` statements. We sometimes use it to return from exceptional cases in the beginning of function, but we try avoid using it mid-function)