Preserves WCS metadata and carries out a proper headers merge for RGB composition. Also fixes a small memleak.