The first scenario (transferring a save game to a digital copy) should be possible. In the 3DS's E-Shop there is a free app called "Save Data Transfer Tool". To quote the store page:
The Save Data Transfer Tool allows Nintendo 3DS users to transfer save data from the packaged version of a game to the downloadable version. Players that originally purchased a physical version of a game will be able to pick up right where they left off with their save data if they decide to download the digital version of the same game. Save data that is transferred to a digital game cannot be moved back to the physical version.
This would seem to move the save from the cartridge to the digital version, not copy. Note that it would probably require an exact game match; as in transferring the save from the Pokemon X cartridge to the Pokemon X digital, not from X to Y. Also as the store description indicates, this is a one-way transfer only. from physical to digital, no going back.
The second scenario (transferring from one cartridge to another) is not, to my knowledge, possible. However, with the Pokemon bank, it might be possible to withdraw stored pokemon on different cartriges, so long as it is your Nintendo Network ID. As the bank will not store items, this is only usefull for transferring pokemon. Your progress throughout the story, and items in your backpack will remain with the save file on the cartridge.