The serailization and deserialization is becoming tougher with these null values.  We will not be able to calculate the correct offset with the above code and existing deserialization logic.  We will have to persist the number of trailing nulls also.
I will make the changes and send it to you. Lot of logic needs to done to identify that a null was written but for consecutive nulls.  And also if it is a trailing null, then we may have then the offset would be populated of the previous element and in the deserialization when we start comparing the previous and the current we are not sure whether the last one was a null.