How to fix an issue with customizer live preview?

Setting up a css.php for this purpose is overkill (or undesirable in any case, as @MarkKaplun states in the other answer).

The smoothest way for previews of css is using jquery (see part 3 of the customizer API).

Since you’re not using the transport argument in your setting, the page is reloaded anyway, so you can simply add the styles in your functions.php using wp_add_inline_style, inside the function that enqueues your style.css. Like this:

add_action ('wp_enqueue_scripts','wpse242256_add_styles');

function wpse242256_add_styles () {
  wp_enqueue_style('main-style', get_template_directory_uri() . '/style.css');
  $custom_css="
    .im_header { background-color: " . get_theme_mod('im_header_bcolor') . '; }
    .im_nav_bar { background-color: ' . get_theme_mod('im_nav_bar_bcolor') . '; }
    ';
  wp_add_inline_style ('main-style', $custom_css);
}