Grain size distributions and photoelectric heating in ionized media