Thermal radiation and amplified spontaneous emission from a random medium