You forgot the carbon. Carbon comes in compounds such as carbohydrates, fats and proteins. The fats and carbohydrates are entirely carbon, hydrogen and oxygen. The protein have in addition to these three elements some nitrogen, sulfur and phosphorus.
The compounds are oxidized as you loose wight. Oxidation here means the addition of oxygen There are other forms of oxidation, but this is the most important types. The molecules are broken down as they oxidize.
Most of oxidized compounds are released as the gases carbon dioxide and water vapor. Some of the nitrogen (from proteins) is released in urea crystals suspended the urine.
I don't know where the sulfur and phosphorus go when protein is oxidized. My suspicion is that these two elements are also released in the urine.
Along with oxidized compounds, some liquid water leaves the body in the urine and in the breath. If water vapor was not excreted in this way, then the body would be bloated after the person has loosed carbohydrate, fats and protein.
The majority of weight lost is released as carbon dioxide and water. A smaller amount of weight is lost as urea in urine. I don't exactly know how the rest of it is lost.