Ab initio electronic structure calculations based on gradient corrected density functional theory were performed on a class of novel quaternary compounds AgPb$_{m}SbTe$_{2+m}$, which were found to be excellent high temperature thermoelctrics with large figure of merit ZT ~2.2 at 800K. We find that resonant states appear near the top of the valence and bottom of the conduction bands of bulk PbTe when Ag and Sb replace Pb. These states can be understood in terms of modified Te-Ag(Sb) bonds. Electronic structure near the gap depends sensitively on the microstructural arrangements of Ag-Sb atoms, suggesting that large ZT values may originate from the nature of these ordering arrangements.