Travelling outside the USA in transition from F1 to H1B

I have an approved H1B petition along with I94 attached at the bottom of the approval notice which is effective from OCT 1 2017 and I have an OPT valid till OCT 9 2017.

Now can I travel outside the USA and reenter on F1(OPT) before Sep 30.Will it invalidate my I94 on my approved H1B petition?

Your guidance is highly appreciated.