But when you heat an object thermal energy is turned in to mass but still is also left as termal energy?
This is a misunderstanding, a very common one, of Einstein's insight. What Einstein proposed is actually this: when internal energy of a body increases by $\Delta E$, its effective mass (measured by accelerating it, or by weighing it) also increases, by amount $\Delta E/c^2$ (similarly if energy of the body decreases). It does not matter what kind of process is changing the internal energy, the body could be accepting some energy due to radiation from remote source, or accepting work from some nearby body via contact mechanical forces.
There is no conversion of energy into mass in physics, because that would mean energy gets lost. There is also no conversion of mass into energy in physics, for the same reason. No energy ever gets created or lost in known processes; in physics, energy can only transform from one kind to another.
If a body accepts heat from the environment (whether mechanical, electromagnetic or other), this energy transforms into internal energy. Einstein realized that no matter the form the energy comes from, if it ends up in the body, then its mass changes as a manifestation of this new addition of energy.
Sometimes people talk about conversion of mass into energy, for example when talking about radioactive decay processes. This is strictly speaking incorrect for the above reasons, but common due to fact that the energy in the final form is more visible or useful (radiation, heat or electrical energy).
But the energy was always there even before the decay, it was just in the form of binding energy of nuclei, and then the decay changed this energy into the more visible form.