You are allowed 72 hours in PEK without a visa if you are in transit. You do not need to do anything in advance. There is a special line for it at PEK immigration or if that line is closed you can use the regular immigration line. Just show your onward boarding pass and be careful you aren't in or don't inadvertently get directed to the line strait back into the departure area.