Calculation of entropy for an isothermal irreversible expansion
Here are the steps to determining the change in entropy for an irreversible process on a closed system:


Use the first law of thermodynamics to determine the final thermodynamic equilibrium state of the system for the irreversible path.
Totally forget about the irreversible path.  It is of no further use.  Focus only on the initial equilibrium state of the system and the final equilibrium state.
Devise a reversible path for the system that takes it from the initial equilibrium state to the final equilibrium state.  This reversible path does not have to bear any resemblance whatsoever to the real irreversible path, other than it must pass through the same initial and final end points.  (Entropy is a function of state).
Calculate the integral of dq/T for the reversible path that you have devised.  This will give you the change in entropy of the system for the irreversible path as well as for the reversible path.


For your problem, this procedure will give you the equation that you have written.  Note that, for the irreversible path, the system temperature matches the surroundings temperature (isothermal) only at the interface with the surroundings, but not throughout the interior of the system.  For an irreversible expansion, this is what we define as "isothermal."