How old is the battery? Since the engine is typically at idle when selecting neutral, it is the point where the bike's charging system has the least output. Thus the battery is called upon to make up the shortfall. If your battery is really weak, it may result in the flickering headlight and the shifting problems.
On the other hand, it could easily be a mechanical gearbox problem. Does rocking the bike forward and back gently help the gears engage or disengage?