My guess: the HTC Gallery is not installed as a system app, so it doesn't have write access to the SD card. This is a restriction in place since Android 4.4 (Kitkat). Since Lollipop a workaround is available, but apps need to be aware of it. The restriction does not apply to system apps, and HTC Gallery is "used" to be a system app and not having to worry about this restriction (which is why it worked on your M9). Just guessing...
You can try and check if this also happens with pictures in the internal storage. If my guess is correct, that should work.