Atomic loss and gain as a resource for non-equilibrium phase transitions in optical lattices