This adds a `write_bhead` utility function and also reduces the scope of some `BHead` variables. The separate `write_bhead` function was quite useful for #129751 and will likely be useful in a potential separate implementation too. Pull Request: https://projects.blender.org/blender/blender/pulls/130457