Question: a bit of background to the question, I'm a junior developer and we have recently been given flexitime which so far is working well as I get to start at 8am and leave at 4:30pm.

Today I arrived at 7:30 (I like to be early so I can have a coffee in the office before I start my work) however no one arrived to open the office until 9am.

So my question is, should I leave at the the normal time (5:30 pm) or when I would usually leave(4:30 pm)?

Answer: 
With all implementations of flextime that I know, there is a set of rules, in particular **core and maximum work hours**. You need to be there at least during core hours (e.g. 10am-2pm), and you may only work during a certain window (e.g. 7am-7pm). Was that not communicated?

If not, then talk to your manager and ask them to set this policy. Then everyone will know what is or is not possible with flextime.

As to today: If you normally start at 8 and leave at 4:30, I don't see why you cannot leave at 4:30 today, too. The time from 7:30 to 8 is probably on you, because it was not clear whether you can start before 8, but if your normal day starts at 8 am, and the door is locked, that's not your fault.
This is a tricky one.

The basic answer is: You were there at the disposition of the employer in the time agreed upon with him; that you did not were able to do work due to factors external to you does not change that. It is not different to, say, staying an hour idle at work because of the computer do not work due to a power outage.

One small "but" is that it may be difficult to prove that you were there at 8 pm; but since you state you are there everyday that sould not be much of an issue. Also any message contacting your coworkers and reporting the issue with the doors should help. Check with your boss that he knowns that you were there at 8:00 am.

The big "but" is that you have just started with flex time, which means that the system still has to be worked out and your employer is still evaluating it. If the employer gets to the conclussion that the system leads to employees working less hours(either if it is not the employees'fault), he may want to return to strict time. I am not saying that it would happen by just one incident, but if it happens more times it could be determinant.