Use the Blue Mushroom,
In World 2, the 3rd ? block away from the boss door, on a bit of floating land near a big spike ball.
In World 5 the only way to get one is in a Roulette Block, one of those blocks that cycle through Items and you hit it at the right time to get a item.
Another strategy is to get a Mini Mushroom from a Toad house and keep it in your inventory and use it after you deal some damage to the boss, you only have to kill the boss as Mini Mario, because when you beat the boss and Mario goes chasing after Bowser Jr. he falls into a crack and goes to the alternate world.