Both of these sentences are correct. In these examples, either simple past OR past perfect is okay. That is, we don't have to use " had gone" because the conjunction " before" tells us clearly that the action of going to post office occurred before the action of arriving at school. But if we have a different conjunction which does not so clearly tell us the sequence of actrions, such as "when", for example, then we would probably need to use past perfect in the when clause to clearly indicate that action was finished before the other action occurred. For example:
c. "When I had eaten my dinner, I watched a movie."
Compare c. with the following example :
d. "When I ate my dinner, I watched a movie." (in this sentence, we're not sure if we ate while we watched the movie , or if we finished eating first)