Exact approach to the thermodynamics of an open two-level quantum system