Swap args, support writing compressed files