Interesting problem. If the pilot stays on when just in pilot mode it makes me think no on the thermocouple, but stranger things have happened. It could be that when the burner is on, it is "blowing" the pilot away from the thermocouple and it is not staying hot enough?
Other thing you could do is take a multimeter and check continuity on the safety switches when it quits working. Maybe you have one intermittently malfunctioning?