Possible to make mirroring of laptop screen to an HDMI device (TV) smoother to use?

I like to use my laptop display at 1366 x 768 pixels.

I can plug in my TV to my HDMI port, but it seems that the HDMI can only support 1280 x 720 pixels, so the system sets both screens to that resolution.

However, when I disconnect the HDMI cable, the laptop display stays at 1280 x 720 and I have to change it back to 1366 x 768 via the Monitor Preferences dialogue.

The sound is not automatic, neither at the beginning of using HDMI nor at the end.
At the beginning I have to go to System->Preferences->Hardware->Sound;
click on Output tab; select "Built-in Audio Digital Stereo (HDMI)" in order to hear sound through the TV speakers.
When I have finished I have to go to System->Preferences->Hardware->Sound;
click on Output tab; select "Built-in Audio Analogue Stereo" in order to hear sound through the laptop speakers.

Is there any way of automatically restoring the higher resolution display at the end of using HDMI and of automatically switching the sound to the desired device?

P.S. A little of the image gets lost off the edges of the TV screen.

(This is Ubuntu Mate 16.04 on a Toshiba Satellite.)

It will be smoother when switching off mirroring (“Same image in all monitors”).
You will get extended desktop where you can configure both monitors with different resolutions.

Yes, although it takes a little getting used to. I’ve put a Firefox tab on the extended desktop of workspace 4 where I can play full screen video.

Now I just have to deal with
(a) losing the edges of my image and
(b) getting sound to switch between devices automatically.

I only plug in the HDMI when I want to watch TV/video. The rest of the time my laptop moves around, so the panel for sound is a nuisance. Could I write a script for this?

It looks like this is a general problem with Linux:

Well, in the end I bought a Chromecast and an Android tablet. They work very well, no need to think about screen resolution or sound output.