Are Masterwork weapons limited to a +1 bonus, or can the bonus go all the way to +5? The reason I ask is the books usually refer to items with a bonus as magical items, but the books also say that all magic weapons and armor are masterwork.
Limited to +1, overridden by magic bonuses.
Masterwork weapons have a +1 enhancement bonus to hit (but not to damage) because they are well-crafted. Magic bonuses to weapons are enhancement bonuses (which apply to both hit and damage rolls) as well. Because they both have the "enhancement" descriptor, these bonuses to hit do not stack with each other. All weapons must be masterwork in order to be valid targets of enchantment.
Thus a masterwork weapon and a +1 weapon have the same +1 enhancement bonus twice and it doesn't stack. A masterwork +4 weapon has a +1 bonus and a +4 bonus of the same type, and so it's a +4 weapon.
A weapon either is or is not Masterwork; there are not levels of Masterwork as there are for Magic weapons. If a weapon is Masterwork, it gets a +1 enhancement bonus on attack rolls.
A weapon can only be made Magic if it is already Masterwork. Magic weapons are not called a “magic longsword” or whatever, they’re referred to by their enhancement bonus (and any other special abilities), e.g. “+1 longsword.” At a minimum, a Magic weapon has a +1 enhancement bonus to both attack and damage rolls.
The Magic weapon bonus, being of the same type (enhancement) as the Masterwork bonus, overlaps and does not stack with the Masterwork bonus. So a +1 weapon has a +1 enhancement bonus to attack, and a +1 enhancement bonus to attack and damage. Because of the type overlap, the weapon’s wielder adds +1 to both attack and damage, but not +2 to attack and +1 to damage.