Buffer png writes and flush them all at once

* This should half the time to render pages with many formulas

bug: 56769
Change-Id: I5edf979c31fe12098eba1d1df52c9cd3251bd115