Improve the performance of PngWriter._build_image_data_bd_any()