Add flatten property for image spec

Allow to set a flatten property in image spec to collapse all layers of an image.