Wrong image from API SUTextureWriteToFile()

When I extracted the image file from SketchUp file, I found the API cannot save the correct image file.

Source SketchUp file:
222.skp (186.6 KB)

In SketchUp:

The image file from SUTextureWriteToFile():

Could anyone take a look at this SUTextureWriteToFile() and fix the issue for SketchUp SDK?

bits-per-pixel is not 32 bits. if the width is Less than 4 bytes, filled with 4 bytes