Today the black flag with skull-and-crossbones has been the stereotypical image of a pirate flag. However, real pirate flags were much more diverse in appearance and varied from individual pirate to pirate. Commonly known as the "Jolly Roger", the sight of the black flag hoisted on an approaching ship often caused enough fear in the targeted ship's crew that it was often reason enough for an immediate surrender to the pirates. Contrary to modern belief, the pirate's black flag generally only began widespread use in the late 1600's and early 1700's. Previous to this, pirates as a whole flew several different type of flags, ranging from standard national flags to solid colors (generally red or black.)
The Jolly Roger often displayed death or scary images - skulls, bones, swords/daggers, and also hourglasses. While bones and weapon images obviously were signs of death, the hourglasses were used to denote that time was running out for the pirates' enemy to surrender before the pirates were unleashed upon them. The main reason for the pirate flag was to make the enemy surrender without much of a fight, if at all, so the more fearsome the flag (or the pirate's reputation too) then the chances were higher of an initial surrender.
There are several theories as to the origin of the term "Jolly Roger", the main belief is that it is a French to English translation. Initially, a plain red flag was flown to show that the no mercy would be given ("no quarter given"), or in another words - death to all. So a ship flying a red flag actually caused more fear because it meant no life would be spared. It is from this red flag that it is believed the term "Jolly Roger" was derived from. In French, "jolie rouge" translates approximately into "beautiful/lovely red" which may have been altered into "jolly roger" over time.
Another theory suggests that "Jolly Roger" was a take on the devil's nickname. Around that time (18th century) the devil was known as Old Roger, so it is possible that the pirate flag's nickname was derived from the devil's nickname since both dealt with death.
It is interesting to note that just plain red flags and plain black flags were also used as pirate flags - red for no quarter and black for standard battle. It is mentioned in some cases where a ship has come under attack from numerous pirate ships, some flying a black bone-type flag and others with red flags or pennants from the masts. It is also seen that some pirates initially flying a black flag into battle would lower it and raise a red one in its place if the other ship resisted too much. In other cases, the black Jolly Roger type flag was used in combination with red flags or pennants and also standard national flags.
Not all pirates had their own pirate flag either, some flew only a national flag (English, Spanish, French, Dutch, etc.) Even if they had their own pirate flag, they would often also have several national flags as well in order to mask their true identity. Only when a ship approached would a flag be raised, so if a ship was sighted and a closer inspection followed then the pirate ship might lure them in by raising a national flag hoping it would be friendly to the other ship. If their ruse worked by bringing the other ship closer, then the pirates would swiftly lower that flag and raise the Jolly Roger in its place. And for the pirates, hopefully that meant the other ship would surrender at this point after seeing their true identity.