Note that during a fall of a ball, the air friction is negligible, and we call it a free fall, only $\vec{P}$ is applied, the work of this force is given by : $W(\vec{P})=mgl$.
In this case, the air slows the ball falling, so there absolutely is two forces, the weight and the air contact, let it be $\vec{f}$, its work will be : $W(\vec{f})=\vec{f}.\vec{l}$
The speed of this ball isn't constant so the $\sum W \neq 0 \Leftrightarrow \Delta E_k\neq0$ and the variation of potential energy $\Delta E_p=-W(\vec{P})$
Back into the free fall; $\Delta E_k=\sum W \Leftrightarrow \frac{1}{2}mv_f^2-\frac{1}{2}mv_i^2=W(\vec{P})$
$\frac{1}{2}mv_f^2-\frac{1}{2}mv_i^2=-mg(z_f-z_i)$
$\frac{1}{2}mv_f^2+mgz_f=\frac{1}{2}mv_i^2+mgz_i$
Adding the Constant of the potential energy, we get:
$\frac{1}{2}mv_f^2+mgz_f+C=\frac{1}{2}mv_i^2+mgz_i+C$
Note that : $E_p=mgz+C$ we will have :
$E_{k_f}+E_{p_f}=E_{k_i}+E_{p_i} \Leftrightarrow E_{m_f}=E_{m_i} \Leftrightarrow \Delta E_m=0$
Therefore during a free fall the mechanical energy (Kinetic and potential) is conserved, but what about this case ?
I mentioned that the ball's speed isn't constant and there's a negative friction force (The work is negative because of the angle note that $W(\vec{f})=f.l.cos(\pi)=-f.l$), obviously the mechanical energy isn't conserved and that's why:
$$\Delta E_k= \sum W$$
In this case there's two forces, thus there's two works
$$\frac{1}{2}mv_f^2-\frac{1}{2}mv_i^2=W(\vec{P})+W(\vec{f})$$
We're doing the same thing here, but there's a new factor which is $W(\vec{f})$, We'll have :
$$ \Delta E_m=W(\vec{f})$$
Now how this friction is transformed to a heat ?
Well to answer this question, you'll need the first law of thermodynamics $$\Delta U=Q+W$$
but I see that it's obvious without any mathematical proof, by the way $\Delta E_m=-Q$ so we can conclude that $W(\vec{f})=-Q$, so the friction is transformed to a heat (thermal energy) the sign minus is conventional. and you can conclude that when there's any friction force (external force) its work is converted into a thermal energy.