Set the active layer to a background layer right before saving so that the defined bgColor is used as background color for the tiles