When you get to the gate, go half-way through and then immediately go back. The gate should close. Press against it while it opens. When it opens fully, you will be able to get through. When you get to the last room where the princess is, stop running or she will kill you.