fix filename when saving gcode

In the proposed filename, the last character was always missing.
Replace some similar string slicing/rfind with splitting.
Merge pull request #581 from martinxyz/SteamEngine

fix filename when saving gcode