loaders/png: autodetect image type and save correct rgb/gray/palette images with and without transparency