def scale_width(w, w_factor):
    """
    Scales width given a scale factor
    """
    w *= w_factor
    new_w = (int(w + 4) // 8) * 8
    new_w = max(8, new_w)
    if new_w < 0.9 * w:
        new_w += 8
    return int(new_w)