Reducing thermal errors with topology optimization and distributed cooling