Accurate calculations of thermionic electron gun properties