Refactor oat file writing.
am: 0d192d2c08

Change-Id: I72901bf0404ff6c15aad760db52c9e870e36d78a