Near-field thermodynamics and nanoscale energy harvesting