Photoionization of potassium atoms from the ground and excited states