The gaps in your resume aren't nearly as bad as you may think.
While you may be worried that HR managers and corporate recruiters will look down at a timeline disparity in your resume, in a recent interview by the website, The Muse, a few HR managers went on record as saying not to presume too much. Should questions arise regarding your timeline gap simply reply politely.
For example, if you lost your job never say, "the company/boss/(insert entity) had it out for me!"
Instead say something along the lines of: "it wasn't a good fit/the company had budget cuts... however, I am proud of my achievements that I did with the company."
Alternately, if you were the one to cut ties with the company in order to sow your wild oats, never say: "Partying all over Europe and Asia was much more satisfying than a corporate job," but instead say something like: "I took some time overseas to learn more about myself and the world and how that would better inform me in how to help my career manifest in the best possible way."
Now, what to say if you went back to school?
Instead of saying something like, "I'm not sure what I want to do with my life," say something like: "By going back to school, I wanted to enlarge my career options and qualifications instead of limiting myself."
But what if you had some health problems?
Don't say: "Things were rough," but instead say: "I took some time to concentrate on getting better in order to make sure I could better achieve the career goals I have in mind. By doing this, I was able to make a full recovery and proceed forth tot he next stage in my professional life."
And if you took time off to take care of family, never say something callous like, "it was all on me!" but instead say something like: "I meditated on this issue and what I took away from it was that it was a top priority for me. In spite of all this, I never lost sight of my professional goals and I'd like to refocus on my career."