I wish the pictures worked for you, they would make things easier to work out.
If the gearbox is a common one, changing sprocket size should be easy. Changing the internal gears, not so easy if even possible at all.
3 things will cause chain problems, perhaps you can check them out?
1. Proper alignment. A chain does not like to run crookedly. The sprockets need to be in perfect alignment with each other.
2. Proper tension. A chain that is too loose will jump off of the sprockets, especially if the sprockets are not properly aligned. Proper tension depends on the overall chain run length. 1/2 inch free play is most common.
3. Poorly made chain. A chain with stiff or crooked links will never wrap around the sprockets properly and should be replaced. Sometimes stiff links can be worked loose by carefully spreading the offending link plates open a teeny bit and/ or working the link back and forth until it wears a little and frees up.