fix bug when imagesAsPng is false