Heat-flow methods for harmonic maps of surfaces and applications to free boundary problems