export all layers instead of only the active

In the current version the script only saves the active layer – that is not what the user expects. So with this change it merges all visible layers (in a copy) and exports the result.